<!-- 业务跟单控件 -->
<template>
  <a-space direction="vertical" style="width: 100%">
    <a-select
      v-model="modelValue"
      @click="getData"
      :field-names="fieldName"
      :options="data.list"
      placeholder="请选择"
    >
    </a-select>
  </a-space>
</template>

<script lang="ts" setup>
  import { reactive, computed, ref, onMounted } from 'vue';
  import { GetPersonnelinformation } from '@/api/home/System settings/personal-information';

  const props = withDefaults(
    defineProps<{
      props: { [propName: string]: any };
      name?: string;
      required?: boolean;
      oneValue: any;
      regex?: {
        [name: string]: {
          role: any;
          name: any;
        };
      };
    }>(),
    {}
  );
  const emit = defineEmits(['update:oneValue']);
  const modelValue = computed({
    get() {
      return props.oneValue;
    },
    set(val) {
      emit('update:oneValue', val);
    },
  });
  interface Item {
    id: number;
    name: string;
    [name: string]: string | number;
  }
  interface DataType {
    list: Item[];
  }
  const fieldName = { value: 'id', label: 'name' };
  const data = reactive<DataType>({ list: [] });
  const getData = async () => {
    let res = await GetPersonnelinformation({
      page: 0,
      size: -1,
    });
    data.list = res.content.data;
  };
  onMounted(() => {
    if (props.oneValue) getData();
  });
</script>

<style scoped lang="less"></style>
